<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>央票通</title>
	<link rel="stylesheet" href="./resource/css/index.css">
	<link rel="stylesheet" href="./resource/css/user_name.css">
</head>
<body>
<!-- 头部 -->
@include('common.index_head');
<!-- 个人中心 -->
<div class="cont-user">
	<div class="user-name">
		<div class="main">
			<div class="name-cont">
				<div class="title">
					<span>找回密码</span>
				</div>
				<div class="form form-pass form-pass-1">
					<form action="/verify_user_mobile" onsubmit="return check_all()" method="post">
						<div class="pass-tit">
							<div class="number">1</div>
							<div class="til">输入手机号</div>
						</div>
						<div class="form-group">
							<label for="">手机号</label>
							<input type="text" class="form-control" placeholder="请输入手机号码" id="mobile" name="mobile"><span id="t_mobile"></span>
						</div>
						<div class="form-group form-code">
							<label for="">验证码</label>
							<input type="text" class="form-control"  id="captcha"  name="captcha">
							<div class="code">
								<img onclick="this.src='/captcha?'+ Math.random()"  src="/captcha">
							</div><span id="t_captcha"></span>
						</div>
						<input type="submit"  value="下一步" class="btn btn-login">
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- footer -->
@include('common.index_foot')

<script src="./resource/js/jquery-1.11.3.min.js"></script>
<script src="./resource/js/index.js"></script>
<script>

function check_all()
{
	var captcha = document.getElementById('captcha').value;
	var mobile = document.getElementById('mobile').value;
	var status = false;
	if(captcha){
		if(mobile) {
			var ajax = new XMLHttpRequest();
			ajax.onreadystatechange = function () {
				if (ajax.readyState == 4) {
					if (ajax.responseText == 2) {
						document.getElementById("t_captcha").innerHTML = "<span style='color:red'>验证码有误</span>";
					} else {
						document.getElementById("t_captcha").innerHTML = "";
					}
					if (ajax.responseText == 0) {
						document.getElementById("t_mobile").innerHTML = "<span style='color:red'>手机号有误</span>";
					} else if (ajax.responseText == 1) {
						status = true
					}
				}
			}
			//与服务器建立连接
			ajax.open('post', '/js_verify_user_mobile', false);
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			//处理请求
			ajax.send('captcha=' + captcha + '&mobile=' + mobile);
			return status
		}else{
			document.getElementById("t_mobile").innerHTML = "<span style='color:red'>手机号不能为空</span>";
			return false;
		}
	}else{
		document.getElementById("t_captcha").innerHTML = "<span style='color:red'>验证码不能为空</span>";
		return false;
	}
}


</script>
</body>
</html>